<!DOCTYPE html>
<html>
<head>
    <title>平涛</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="description" content="Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.
">

    <!--新增2017-03-02-->
    <script src="__PUBLIC__/Wechat/js/jquery.1.7.2.min.js"></script>
    <script src="__PUBLIC__/Wechat/js/mobiscroll_002.js" type="text/javascript"></script>
    <script src="__PUBLIC__/Wechat/js/mobiscroll_004.js" type="text/javascript"></script>
    <link href="__PUBLIC__/Wechat/css/mobiscroll_002.css" rel="stylesheet" type="text/css">
    <link href="__PUBLIC__/Wechat/css/mobiscroll.css" rel="stylesheet" type="text/css">
    <script src="__PUBLIC__/Wechat/js/mobiscroll.js" type="text/javascript"></script>
    <script src="__PUBLIC__/Wechat/js/mobiscroll_003.js" type="text/javascript"></script>
    <script src="__PUBLIC__/Wechat/js/mobiscroll_005.js" type="text/javascript"></script>
    <link href="__PUBLIC__/Wechat/css/mobiscroll_003.css" rel="stylesheet" type="text/css">
    
    
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Wechat/css/weui.min.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Wechat/css/jquery-weui.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Wechat/css/style.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Wechat/css/aui-iconfont.css">

    <style type="text/css">
        .weui_panel:after{border-bottom: none !important;  }
        .input_con{width: 88% !important;}
        .weui_cell_bd{margin:5px;}
        input{border: none}
        a{color: red}
        .weui_cell{padding: 0px !important;}
        input,textarea{background: #FAFAFA}
        .weui_cell:before{border-top: none !important;}
        .weui_navbar_item{padding: 17px 11px !important}

    </style>

</head>


<body ontouchstart>
    <form>
    <div class="weui_tab">
        <div class="weui_navbar weui_navbar1">
            <div class="weui_navbar_item weui_bar_item_on">
                <div style="text-align:left;float:left">
                    <a href="{:U('Work/index')}">
                        <span class="aui-iconfont aui-icon-left"></span>
                    </a>
                </div>
                <span>工作总结</span>
                <div class="f-r">
                    <span class="f-s1" style="cursor:pointer;color:green;" id="sub" onclick="tj()">添加</span>
                </div>
            </div>
        </div>

        <div class="weui_tab_bd">
            <div class="zj">
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label for="date" class="weui_label">总结日期：</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <input class="weui_input" id="date" type="text" name="date" value="">
                    </div>
                </div>
            </div>

            <div class="zj m-t1">
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label for="" class="weui_label">总结内容：</label></div>
                </div>

                <input type="hidden" name="num" id="num" value="3" />  <!-- 存放内容数量 -->

                <div class="weui_cell l-h2 input_box">
                    <!-- <div class="weui_cell_hd"><label for="" class="weui_label lab1">1.</label></div> -->
                    <div class="weui_cell_bd weui_cell_primary">
                        <textarea class="weui_textarea " id="content" name="content" placeholder="请输入内容" rows="5"></textarea>
                    </div>
                </div>
                <!-- <div class="weui_cell l-h2 input_box">
                    <div class="weui_cell_hd"><label for="" class="weui_label lab1">2.</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <textarea class="weui_textarea textarea_1" name="content2" placeholder="请输入内容" rows="1"></textarea>
                    </div>
                </div>
                <div class="weui_cell l-h2 input_box">
                    <div class="weui_cell_hd"><label for="" class="weui_label lab1">3.</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <textarea class="weui_textarea textarea_1" name="content3" placeholder="请输入内容" rows="1"></textarea>
                    </div>
                </div>

                <div class="text-cen">
                    <a href="#" onclick="add()" style="color:blue;">新增一行+</a>
                </div> -->
            </div>

        </div>

        <include file="Index/footer" />

    </div>
    </form>

    <!--<script type="text/javascript" src="__PUBLIC__/Wechat/js/jquery-2.1.4.js"></script>-->
    <script type="text/javascript" src="__PUBLIC__/Wechat/js/fastclick.js"></script>
    <!-- <script type="text/javascript" src="__PUBLIC__/Wechat/js/autosize.js"></script> -->
    <script type="text/javascript" src="__PUBLIC__/Wechat/js/jquery-weui.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Wechat/layer_mobile/layer.js"></script>
    <script>
        $(function() {
            FastClick.attach(document.body);
        });

        //autosize(document.querySelectorAll('textarea'));
        
        // 修改2017-03-02
        // $("#date").datetimePicker({
        //     title: '请选择总结日期',
        //     // min:new Date(-3),
        //     max:new Date(),
        //     times: function () {
        //         return [];
        //     },
        //     onChange: function (picker, values, displayValues) {
        //         //console.log(values);
        //     },
        // });
        
        
        // 新增2017-03-02
        $(function () {
            var currYear = (new Date()).getFullYear();  
            var currDay=new Date();
            var opt={};
            opt.date = {preset : 'date'};
            opt.datetime = {preset : 'datetime'};
            opt.time = {preset : 'time'};
            opt.default = {
                theme: 'android-ics light', //皮肤样式
                    display: 'modal', //显示方式 
                    mode: 'scroller', //日期选择模式
                dateFormat: 'yyyy-mm-dd',
                lang: 'zh',
                showNow: true,
                nowText: "今天",
                    startYear: currYear - 10, //开始年份
                    endYear: currYear + 10, //结束年份
                    maxDate:new Date(),
                    minDate:new Date(new Date()-48*60*60*1000)
          };
    
            $("#date").mobiscroll($.extend(opt['date'], opt['default']));
            var optDateTime = $.extend(opt['datetime'], opt['default']);
            var optTime = $.extend(opt['time'], opt['default']);
            $("#appDateTime").mobiscroll(optDateTime).datetime(optDateTime);
            $("#appTime").mobiscroll(optTime).time(optTime);
            });
        

        // 添加新行
        /*function add(){
            var len = $('.input_box').length + 1;
            var content = '<div class="weui_cell l-h2 input_box"><div class="weui_cell_hd"><label for="" class="weui_label lab1">' + len + '.</label></div><div class="weui_cell_bd weui_cell_primary"><textarea class="weui_textarea textarea_1" name="content' + len + '" placeholder="请输入内容" rows="1"></textarea></div></div>';
            $('.input_box:last').after(content);
            $('#num').val(len);
        }*/

        // 添加
        function tj(){
            //$('form').submit();
            if( !$('#date').val() ){
                layer.open({
                    content: '请选择总结日期',
                    skin: 'msg',
                    time: 1 ,
                });
            }else{
                if( $.trim($('#content').val()) ){
                    $('#sub').attr('onclick','');  // 避免重复提交
                    $.ajax({
                        url: "{:U('Work/addCheck')}",
                        type: "POST",
                        data: $('form').serializeArray(),
                        success: function(msg){
                            //console.log(msg);
                            layer.open({
                                content: msg['content'],
                                skin: 'msg',
                                time: 1 ,
                            });
                            if(msg['state'] == 200){
                                setTimeout('window.location.href = "{:U('Work/index')}"', 1000);
                            }else{
                                $('#sub').attr('onclick','tj()');  // 添加出错，允许重新提交
                            }
                        }
                    });
                }else{
                    layer.open({
                        content: '请填写总结内容',
                        skin: 'msg',
                        time: 1 ,
                    });
                    $('#sub').attr('onclick','tj()');  // 添加出错，允许重新提交
                }
            }

        }
    </script>
</body>
</html>
